package by.jtraining.london.web.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

import static by.jtraining.london.constants.Constants.ROLE;

public abstract class AbstractUserInterceptor implements Interceptor{

	private static final long serialVersionUID = 1296623814088501754L;
	protected static final String INDEX = "index.do";

	@Override
	public void destroy() {}

	@Override
	public void init() {}
	
	protected boolean checkUserRole(ActionInvocation invocation, String userRole){
		String role = (String) invocation.getInvocationContext().getSession().get(ROLE);
		return role.equals(userRole); 
	}
}
